<template>
    <div>
      <br />
      <!--死亡管理-查询 -->
      <el-form :inline="true" :model="form" class="demo-form-inline">
        <el-form-item label="称重日期" >
          <el-date-picker v-model="form.sDate" type="date" style="width: 230px"  value-format="YYYY-MM-DD" clearable />-
          <el-date-picker v-model="form.eDate" type="date" style="width: 230px"  value-format="YYYY-MM-DD" clearable />
        </el-form-item>
        <el-form-item label="羊只耳号">
          <!-- <el-input v-model="form.Earbugles" placeholder="羊只耳号" clearable /> -->
          <el-select v-model="form.Earbugles" style="width: 230px" clearable>
            <el-option label="全部" :value="0"></el-option>
              <el-option
                v-for="item in ear"
                :key="item.id"
                :label="item.name"
                :value="item.name"
              />
            </el-select>          
        </el-form-item>
        <el-form-item label="死亡原因">
          <el-select v-model="form.DeathCause" style="width: 230px" clearable>
            <el-option label="全部" :value="0"></el-option>
            <el-option
              v-for="item in DeathCauseList"
              :key="item.value"
              :label="item.name"
              :value="item.value"
            />
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-button type="danger" @click="GetDeathInfo">查询</el-button>
          <el-button>重置</el-button>
        </el-form-item>
      </el-form>
      <el-divider />
      <div>
          <el-button type="danger" size="large" @click="OpenVisible" :icon="Plus">新增</el-button>
          <el-button type="danger" size="large" @click="BatchDel()" :icon="Delete">删除</el-button>
          <el-button type="danger" size="large" @click="BatchTrue()" :icon="Stamp">审核</el-button>
          <el-button type="danger" size="large" @click="BatchFalse()" :icon="Stamp">重新审核</el-button>
      </div>      
      <br>
      <div>
          <div v-if="TagBool">
              <el-tag style="width:1920px;color: black;height: 50px;" type="danger" :iocn="Delete">
                  <spna style="font-size: 15px">
                      <Warning style="width: 1em; height: 1em; margin-right: 8px" color="red" />
                      <span style="margin-right: 1800px">已选择 {{ TagCount }} 项</span>
                  </spna>
              </el-tag>
          </div>
          <div v-else>
              <el-tag style="width:1920px;color: black;height: 50px;" type="success" :iocn="Delete">
                  <spna style="font-size: 15px">
                      <SuccessFilled style="width: 1em; height: 1em; margin-right: 8px" color="green" />
                      <span style="margin-right: 1800px">已选择 {{ TagCount }} 项</span>
                  </spna>
              </el-tag>
          </div>
      </div> 
      <br />
      <!--死亡管理-列表 -->
      <el-table :data="DeathManageList" stripe style="width: 100%" border @selection-change="handleSelectionChange">
        <el-table-column type="selection" align="center" />
        <el-table-column label="序号" :fixed="true">
          <template v-slot="a">
            <span>{{ a.$index + (page.pageIndex - 1) * page.pageSize + 1 }}</span>
          </template>
        </el-table-column>
        <el-table-column prop="ExamineType" label="审核状态" width="110px" :fixed="true">
            <template v-slot="scope">
              <el-tag type="success" v-if="scope.row.ExamineType==true">审核通过</el-tag>
              <el-tag type="danger" v-else-if="scope.row.ExamineType==false">未审核</el-tag>
            </template>
        </el-table-column>
        <el-table-column prop="DeathTime" label="死亡日期↓" width="110px">
            <template v-slot="scope">
            <span>{{
                scope.row.DeathTime
                ? scope.row.DeathTime.replace("T", " ").substring(0, 10)
                : null
            }}</span>
            </template>
        </el-table-column>
        <el-table-column prop="Earbugles" label="羊只耳号" width="110px" />
        <el-table-column prop="DeathCause" label="死亡原因" width="110px" >
            <template v-slot="data">
              <span v-if="data.row.DeathCause == 1">腹泻</span>
              <span v-else-if="data.row.DeathCause == 2">肺炎</span>
              <span v-else-if="data.row.DeathCause == 3">产前瘫</span>
              <span v-else-if="data.row.DeathCause == 4">产后瘫</span>
              <span v-else-if="data.row.DeathCause == 5">酸中毒</span>
              <span v-else-if="data.row.DeathCause == 6">应激猝死</span>
              <span v-else-if="data.row.DeathCause == 7">梭卷</span>
              <span v-else-if="data.row.DeathCause == 8">尿结石</span>
              <span v-else-if="data.row.DeathCause == 9">发热</span>
              <span v-else-if="data.row.DeathCause == 10">脱肛</span>
              <span v-else-if="data.row.DeathCause == 11">黄疸</span>
              <span v-else>猝死</span>
            </template>
        </el-table-column>
        <el-table-column prop="Breed" label="品种" width="110px">
        <template v-slot="data">
            <span v-if="data.row.Breed == 1">杜泊</span>
            <span v-else-if="data.row.Breed == 2">澳洲白 </span>
            <span v-else-if="data.row.Breed == 3">萨福克</span>
            <span v-else-if="data.row.Breed == 4">杜湖</span>
            <span v-else-if="data.row.Breed == 5">杜杜湖</span>
            <span v-else-if="data.row.Breed == 6">萨杜湖</span>
            <span v-else-if="data.row.Breed == 7">澳湖</span>
            <span v-else-if="data.row.Breed == 8">湖羊</span>
            <span v-else>澳杜湖</span>
        </template>
        </el-table-column>
        <el-table-column prop="Sex" label="性别" width="110px">
            <template v-slot="data">
            <span v-if="data.row.Sex == 1">公 </span>
            <span v-else>母</span>
            </template>
        </el-table-column>
        <el-table-column prop="ReproductiveState" label="繁殖状态" width="110px">
        <template v-slot="scope">
          <span v-if="scope.row.ReproductiveState==1">后备空怀</span>
          <span v-if="scope.row.ReproductiveState==2">返情空怀</span>
          <span v-if="scope.row.ReproductiveState==3">未孕空怀</span>
          <span v-if="scope.row.ReproductiveState==4">流产空怀</span>
          <span v-if="scope.row.ReproductiveState==5">空胎空怀</span>
          <span v-if="scope.row.ReproductiveState==6">断奶空怀</span>
          <span v-if="scope.row.ReproductiveState==7">妊娠</span>
          <span v-if="scope.row.ReproductiveState==8">哺乳</span>
        </template>
      </el-table-column>
        <el-table-column prop="DeathMonth" label="死亡月龄" width="110px" >
          <template v-slot="a">
              <span v-if="a.row.DeathDay/30> 1">
                {{Number(a.row.DeathDay/30).toFixed(0)}}
              </span>  
              <span v-else>0</span>  
          </template>  
        </el-table-column>
        <el-table-column prop="DeathDay" label="死亡日龄" width="110px" />
        <el-table-column prop="DeathDorm" label="死亡栋舍" width="110px" />
        <el-table-column prop="DeathColumns" label="死亡栏位" width="110px" />
        <el-table-column prop="CreateBy" label="创建人" width="110px" />
        <el-table-column prop="CreateDate" label="创建时间" width="110px">
          <template v-slot="scope">
            <span>{{
              scope.row.CreateDate
                ? scope.row.CreateDate.replace("T", " ").substring(0, 19)
                : null
            }}</span>
          </template>
        </el-table-column>
        <el-table-column prop="UpdateBy" label="修改人" width="110px" />
        <el-table-column prop="UpdateDate" label="修改时间" width="110px">
          <template v-slot="scope">
            <span>{{
              scope.row.UpdateDate
                ? scope.row.UpdateDate.replace("T", " ").substring(0, 19)
                : null
            }}</span>
          </template>
        </el-table-column>
        <el-table-column prop="AuditorBy" label="审核人" width="110px" />
        <el-table-column prop="AuditorDate" label="审核时间" width="110px">
          <template v-slot="scope">
            <span>{{
              scope.row.AuditorDate
                ? scope.row.AuditorDate.replace("T", " ").substring(0, 19)
                : null
            }}</span>
          </template>
        </el-table-column>
        <el-table-column prop="DocumentCord" label="单据号" width="110px" />
        <el-table-column  fixed="right" width="110px" label="操作">
          <template v-slot="scope" #default>
            <span v-if="scope.row.ExamineType==false">
            <el-link type="primary" @click="Del(scope.row.DMId)">删除</el-link
            >&nbsp;
            <el-link type="primary" @click="UpdInfo(scope.row.DMId)">修改</el-link>
            </span>
            <span v-else>
               <el-link type="info" disabled>审核完毕</el-link>
            </span>
          </template>
        </el-table-column>
      </el-table>
      <!-- 分页 -->
      <div class="demo-pagination-block">
        <el-pagination
          v-model:current-page="page.pageIndex"
          v-model:page-size="page.pageSize"
          :page-sizes="[10, 20, 30, 50]"
          :background="true"
          layout="total, sizes, prev, pager, next, jumper"
          :total="page.totalCount"
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
        />
      </div>
      <!-- 新增行 -->
      <el-dialog v-model="dialogTableVisible" title="死亡管理" width="80%" style="height: 80%;" :before-close="NewUpdate">
        <div>
          死亡日期:<el-date-picker v-model="DeathInfo.DeathTime" type="date" value-format="YYYY-MM-DD" />
          &nbsp;&nbsp;&nbsp;&nbsp;
          羊只类型: 
          <span v-if="DeathInfo.SheepTypeId==3">
            <el-radio-group v-model="DeathInfo.SheepTypeId"  style="width: 230px;" >
                <el-radio :value="1" size="large">种公</el-radio>
                <el-radio :value="2" size="large">种母</el-radio>
                <el-radio :value="3" size="large">后裔</el-radio>
            </el-radio-group>
          </span> 
          <span v-else>
          <el-radio-group v-model="DeathInfo.SheepTypeId"  style="width: 230px;" >
              <el-radio :value="1" size="large">种公</el-radio>
              <el-radio :value="2" size="large">种母</el-radio>
              <el-radio :value="3" size="large">后裔</el-radio>
          </el-radio-group>
          </span> 
          &nbsp;&nbsp;
          单据号:<el-input v-model="DeathInfo.DocumentCord" style="width: 220px;" ></el-input>
          <br><br>
          <div>
              <el-button type="danger" size="default" @click="addDeath" :icon="Plus"
                  v-if="DeathInfo.DMId == 0">新增</el-button>
              <el-button type="danger" size="default" @click="addDeath" :icon="DocumentChecked"
                  v-else>保存</el-button>
                <el-button type="danger" disabled v-show="DeathInfo.DMId == 0">保存</el-button> 
                <el-button type="danger" disabled v-show="DeathInfo.DMId == 0">撤销</el-button> 
                <el-button type="danger" disabled v-show="DeathInfo.DMId == 0">删除</el-button> 
          </div>
         <br><br>
          <el-table :data="rowList" style="width: 90%" border>
            <el-table-column prop="Earbugles" label="耳号">
                <span>
                    <el-select v-model="DeathInfo.Earbugles"  @change="AddEar" style="width: 220px" clearable>      
                      <el-option
                        v-for="item in ear"
                        :key="item.id"
                        :label="item.name"
                        :value="item.name"
                      />
                    </el-select>
                </span>
            </el-table-column>
              <el-table-column prop="DeathCause" label="死亡原因">
                <span>
                  <el-select v-model="DeathInfo.DeathCause" placeholder="请选择"  clearable>
                        <el-option v-for="item in DeathCauseList" :key="item.value" :label="item.name" :value="item.value" clear />
                    </el-select>
                </span>
            </el-table-column>
              <el-table-column prop="Breed" label="品种">
                <span>
                    <el-select v-model="DeathInfo.Breed" clearable>
                      <el-option v-for="item in BreedList" :key="item.value" :label="item.name" :value="item.value" />
                    </el-select>
                </span>
            </el-table-column>
              <el-table-column prop="Sex" label="性别 ">
                <span>
                  <span v-if="DeathInfo.SheepTypeId==3">
                    <el-select v-model="DeathInfo.Sex" clearable >
                      <el-option v-for="item in SexList" :key="item.value" :label="item.name" :value="item.value" />
                    </el-select>
                  </span>
                  <span v-else>
                    <el-select v-model="DeathInfo.Sex" clearable >
                      <el-option v-for="item in SexList" :key="item.value" :label="item.name" :value="item.value" />
                    </el-select>
                  </span>        
                </span>
            </el-table-column>
            <el-table-column prop="DeathDorm" label="当前栋舍">
                <span>
                    <el-select v-model="DeathInfo.DeathDorm" placeholder="请选择" clearable
                        @change="GetField()">
                        <el-option v-for="item in Cottage" :key="item.Id" :label="item.Name"
                            :value="item.Name" />
                    </el-select>
                </span>
            </el-table-column>
            <el-table-column prop="DeathColumns" label="当前栏位">
                <span>
                    <el-select v-model="DeathInfo.DeathColumns" placeholder="请选择" clearable>
                        <el-option v-for="item in Field" :key="item.Id" :label="item.Name" :value="item.Name" />
                    </el-select>
                </span>
            </el-table-column>
          </el-table>
        </div> 
      </el-dialog>
    </div>
</template>
<script setup lang="ts">
import http from '@/http'
import { ref, reactive, inject, onMounted } from "vue";
import type { AxiosStatic } from "axios";
import { ElMessage, ElMessageBox } from "element-plus";
import { Plus, Delete,Stamp, DocumentChecked, Warning, SuccessFilled } from '@element-plus/icons-vue'
const axios = inject("axios") as AxiosStatic;
const AddEar = () => {
  http.get("MYroute/api/SheepFile/SheepFileConditionFinds?card=" + DeathInfo.Earbugles)
    .then(res => {
    DeathInfo.Breed = res.data.breed;
    DeathInfo.Sex = res.data.sex;
    DeathInfo.DeathDorm = res.data.cottage;
    DeathInfo.DeathColumns = res.data.field;
    DeathInfo.ReproductiveState = res.data.reproductiveState;
  })
}
const handDay = computed(() => {
  var a = map(x=>x.DeathTime);
  DeathManageList.DeathDay = DateDiffer(new Date(a));
  alert(a);
  alert(DeathManageList.DeathDay);
})
const now = computed(() => Date.now())

//计算日期之间的天数
const DateDiffer = (Date_end: any) => {
    //date1结束时间
    let date1 = new Date(Date_end);
    //date2当前时间
    let date2 = new Date();
    // date1 = new Date(date1.getFullYear(), date1.getMonth(), date1.getDate());
    // date2 = new Date(date2.getFullYear(), date2.getMonth(), date2.getDate());
    const diff = date2.getTime() - date1.getTime(); //目标时间减去当前时间
    const diffDate = diff / (24 * 3600 * 1000 ) -1; //计算当前时间与结束时间之间相差天数
    return Math.ceil(diffDate);
};

//添加弹出层初始值
const dialogTableVisible = ref(false);
//调用添加层
const OpenVisible = () => {
  addFormInfo();  
  DeathInfo.DMId = 0;
  DeathInfo.DeathTime = "";
  DeathInfo.DocumentCord = "";
  DeathInfo.SheepTypeId = 1;
  dialogTableVisible.value = true;
}
//新增死亡表单
const DeathInfo = reactive({
  DMId:0,
  DeathTime: "",
  Earbugles: "",
  DeathCause: 0,
  Breed: 0,
  Sex: 0,
  Reproductive: "",
  DeathMonth: 0,
  DeathDay:0,
  DeathDorm: "",
  DeathColumns: "",
  AuditorBy:"",
  AuditorDate: "",
  UpdateBy: "",
  UpdateDate: "",
  CreateBy: "",
  CreateDate: "",
  DocumentCord: "",
  ExamineType:false,
  SheepTypeId:0,
  ReproductiveState:0
});
const NewUpdate = () => {
 rowList.value = [];
 dialogTableVisible.value = false;
}
//新增行表单
var newRow = {
  Earbugles: "",
  DeathCause: 0,
  Breed: 0,
  Sex: 0,
  DeathDorm: "",
  DeathColumns: "",
}
const rowList = ref([]);
//新增行
const rowLength = ref(0);
const addFormInfo = () => {
    DeathInfo.Earbugles = "";
    DeathInfo.DeathCause = 0||null;
    DeathInfo.Breed = 0||null;
    DeathInfo.Sex = 0||null;
    DeathInfo.DeathDorm = "";
    DeathInfo.DeathColumns = "";
    rowList.value.push(newRow);
}
//对应出生状态
const statebirth=ref()
//对应出生状态下拉
const statebirthlist=()=>{
  http.get("MYroute/api/LamBing/GetinsertType").then(res=>{
    statebirth.value=res.data;
  })
}
//添加
const addDeath = () => {
  if (DeathInfo.DeathTime == "") {    
      ElMessage({
          type: "error",
          message: "死亡日期不能为空",
          duration: 2000
      })
    return;
  }
  if (DeathInfo.DocumentCord == "") {    
      ElMessage({
          type: "error",
          message: "单据号不能为空",
          duration: 2000
      })
    return;
  }
  if (DeathInfo.Earbugles == "") {
    
      ElMessage({
          type: "error",
          message: "耳号不能为空",
          duration: 2000
      })
    return;
  }
  if (DeathInfo.DeathCause == null) {    
      ElMessage({
          type: "error",
          message: "请选择死亡原因",
          duration: 2000
      })
    return;
  }
  if (DeathInfo.DMId == 0) {  
    DeathInfo.DeathDay = DateDiffer(new Date(DeathInfo.DeathTime));   
    http.post("first/api/Sheeponly/AddDeathManage", DeathInfo)
        .then(res => {
          if (res.data > 0) {
              ElMessage({
                  type: "success",
                  message: "保存成功",
                  duration: 2000
              })
              //更改档案的死亡离场状态为已死亡
              http.get("MYroute/api/SheepFile/SheepFileConditionFinds?card=" + DeathInfo.Earbugles).then(res => {
                  var form = res.data;
                form.presence = 4;
                statebirthlist();
                  http.put("Mroute/api/SheepFile/SheepFileConditionUpdate", form)
              })
              dialogTableVisible.value = false;
              NewUpdate();
              GetDeathInfo();
          } else if (res.data == -1) {
              ElMessage({
                  type: "error",
                  message: "保存失败，耳号不能重复",
                  duration: 2000
              })
          }
          else {
              ElMessage({
                  type: "error",
                  message: "保存失败",
                  duration: 2000
              })
          }
      })
  }
  else {
    DeathInfo.DeathDay = DateDiffer(new Date(DeathInfo.DeathTime));
    http.post("first/api/Sheeponly/UpdDeathManage", DeathInfo)
    .then(res => {
      if (res.data > 0) {
          ElMessage({
              type: "success",
              message: "保存成功",
              duration: 2000
          })
          //更改档案的死亡离场状态为已死亡
              http.get("MYroute/api/SheepFile/SheepFileConditionFinds?card=" + DeathInfo.Earbugles).then(res => {
                  var form = res.data;
                form.presence = 4;
                statebirthlist();
                  http.put("Mroute/api/SheepFile/SheepFileConditionUpdate", form)
              })
          dialogTableVisible.value = false;
          NewUpdate();
          GetDeathInfo();
      } else if (res.data == -1) {
          ElMessage({
              type: "error",
              message: "保存失败，耳号不能重复",
              duration: 2000
        })
      }
      else {
        ElMessage({
            type: "error",
            message: "保存失败",
            duration: 2000
        })
      }
  })
  }
  
}
//点击修改事件弹出层
const UpdInfo = (DMId: number | any) => {
  addFormInfo();
  if (DMId != 0) {
    http.get("srout/api/Sheeponly/EditDeathManage?DMId="+DMId)
      .then(res => {
        DeathInfo.DMId = res.data.DMId;
        DeathInfo.DeathTime = res.data.DeathTime;
        DeathInfo.Earbugles = res.data.Earbugles;
        DeathInfo.DeathCause = res.data.DeathCause;
        DeathInfo.Breed = res.data.Breed;
        DeathInfo.Sex = res.data.Sex;
        DeathInfo.Reproductive = res.data.Reproductive;
        DeathInfo.DeathMonth = res.data.DeathMonth;
        DeathInfo.DeathDay = res.data.DeathDay;
        DeathInfo.DeathDorm = res.data.DeathDorm;
        DeathInfo.DeathColumns = res.data.DeathColumns;
        DeathInfo.AuditorBy = res.data.AuditorBy;
        DeathInfo.AuditorDate = res.data.AuditorDate;
        DeathInfo.UpdateBy = res.data.UpdateBy;
        DeathInfo.UpdateDate = res.data.UpdateDate;
        DeathInfo.CreateBy = res.data.CreateBy;
        DeathInfo.CreateDate = res.data.CreateDate;
        DeathInfo.DocumentCord = res.data.DocumentCord;
        DeathInfo.SheepTypeId = res.data.SheepTypeId;
        DeathInfo.ExamineType = res.data.ExamineType;
        GetField();
      })
      dialogTableVisible.value = true;
  }
}
//获取选中的数组
const refs = ref([
{DMId:""}
])
//死亡管理列表
const DeathManageList = ref([]);
//查询form
const form = reactive({
  eDate: "",
  sDate: "",
  Earbugles: "",
  DeathCause: "" || null
});
//显示列表
const GetDeathInfo = () => {
    http.get("srout/api/Sheeponly/GetDeathManage", {
        params: {
            pageIndex: page.pageIndex,
            pageSize: page.pageSize,
            Edate: form.eDate,
            Sdate: form.sDate,
            Earbugles: form.Earbugles || null,
            DeathCause: form.DeathCause || null,
        }
    })
    .then(res => {
        DeathManageList.value = res.data.datas;
        page.totalCount = res.data.totalCount;
      page.pageCount = res.data.pageCount;
    })
}
//分页属性
const page = {
  pageIndex: 1,
  pageSize: 10,
  pageCount: 0,
  totalCount: 0,
};
//总页数
const handleSizeChange = (val: number) => {
  page.pageSize = val;
  GetDeathInfo();
};
//总条数
const handleCurrentChange = (val: number) => {
  page.pageIndex = val;
  GetDeathInfo();
};

//选中数据
let ids = "";
const TagBool = ref(true);
const TagCount = ref(0);
const handleSelectionChange = (val: refs | any) => {
    refs.value = val;
    ids = "";
    val.forEach((x: { DMId: string; }) => {
        ids += x.DMId + ",";
    })
    ids = ids.substring(0, ids.length - 1);
    TagCount.value = ids.split(',').length;
    if (ids == "") {
        TagCount.value = 0;
    }
    if (TagCount.value == 0) {
        TagBool.value = true;
    }
    else {
        TagBool.value = false;
    }
}
//单个删除
const Del = (DMId: any) => {
  ElMessageBox.confirm("确定要此数据删除吗?", "提示", {
    confirmButtonText: "确认",
    cancelButtonText: "取消",
    type: "warning",
  })
    .then(() => {
      http
        .delete("first/api/Sheeponly/DelDeathManage?DMId=" + DMId)
        .then((res) => {
          if (res.data > 0) {
            ElMessage({
              type: "success",
              message: "信息删除成功",
            });
              GetDeathInfo();
          } else {
            ElMessage({
              type: "error",
              message: "信息删除失败",
            });
          }
        });
    })
    .catch(() => {
      ElMessage({
        type: "info",
        message: "Delete canceled",
      });
    });
};
//批量删除
const BatchDel = () => {
  let idss = refs.value.map(x => x.DMId);
  if (refs.value.length == 0) {
    ElMessage.error("至少选择一项");
    return;
  }
  ElMessageBox.confirm("确定要此数据删除吗?", "提示", {
    confirmButtonText: "确认",
    cancelButtonText: "取消",
    type: "warning",
  })
    .then(() => {
      http
        .post("first/api/Sheeponly/BatchDeathManage?Array=" + idss)
        .then((res) => {
          if (res.data > 0) {
            ElMessage({
              type: "success",
              message: "信息批量删除成功",
            });
            GetDeathInfo();
          } else {
            ElMessage({
              type: "error",
              message: "信息批量删除失败",
            });
          }
        });
    })
    .catch(() => {
      ElMessage({
        type: "info",
        message: "Delete canceled",
      });
    });
}
//审核通过
const BatchTrue = () => {
  let idss = refs.value.map(x => x.DMId);
    if (refs.value.length == 0) {
      ElMessage.error("至少选择一项");
      return;
    }
    ElMessageBox.confirm("确定要执行此操作吗?", "提示", {
      confirmButtonText: "确认",
      cancelButtonText: "取消",
      type: "warning",
    })
    .then(() => {
      http
        .post("first/api/Sheeponly/BatchTrueDeathManage?Array=" + idss)
        .then((res) => {
          if (res.data > 0) {
            ElMessage({
              type: "success",
              message: "信息审核成功",
            });
            GetDeathInfo();
          }
          else if (res.data == -1) {
            ElMessage({
              type: "error",
              message: "抱歉 选中的数据有误,请重新选择！",
            });
          }
          else {
            ElMessage({
              type: "error",
              message: "信息审核失败",
            });
          }
        });
    })
    .catch(() => {
      ElMessage({
        type: "info",
        message: "Delete canceled",
      });
    });
}
//重新审核
const BatchFalse= () => {
let idss = refs.value.map(x => x.DMId);
    if (refs.value.length == 0) {
      ElMessage.error("至少选择一项");
      return;
    }
    ElMessageBox.confirm("确定要执行此操作吗?", "提示", {
      confirmButtonText: "确认",
      cancelButtonText: "取消",
      type: "warning",
    })
    .then(() => {
      http
        .post("first/api/Sheeponly/BatchFalseDeathManage?Array=" + idss)
        .then((res) => {
          if (res.data > 0) {
            ElMessage({
              type: "success",
              message: "信息审核成功",
            });
            GetDeathInfo();
          }
          else if (res.data == -1) {
            ElMessage({
              type: "error",
              message: "抱歉 选中的数据有误,请重新选择！",
            });
          }
          else {
            ElMessage({
              type: "error",
              message: "信息审核失败",
            });
          }
        });
    })
    .catch(() => {
      ElMessage({
        type: "info",
        message: "Delete canceled",
      });
    });
}
//耳号
const ear = ref()
//品种集合
const BreedList = ref([
  {
    value: "",
    name: "",
  },
]);
//性别集合
const SexList = ref([
  {
    value: "",
    name: "",
  },
]);
//死亡原因
const DeathCauseList = ref([
  {
    value: "",
    name: "",
  },
]);
//集合
const GetDeathCauseList = () => {
    http.get("MYroute/api/SheepFile/SheepFileConditionEard").then(res=>{
        ear.value=res.data;
    })
    http.get("srout/api/Sheeponly/GetDeathCause").then((res) => {
        DeathCauseList.value = res.data;
    });
    http.get("srout/api/Breeding/GetSex").then((res) => {
      SexList.value = res.data;
    });
    http.get("srout/api/Breeding/GetBreed").then((res) => {
      BreedList.value = res.data;
    });
};
 
//栋舍集合
const Cottage = ref([]);
//栋舍下拉方法
const GetCooter = () => {
    http.get("OrganizationRead/api/Cottage/HandleGetCot").then(res => {
        Cottage.value = res.data;
    })
}
//栏位集合
const Field = ref([]);
//栏位下拉方法
const GetField = () => {
    http.get("OrganizationRead/api/Field/HandleGetSheepFarm?Id=" + DeathInfo.DeathDorm).then(res => {
        Field.value = res.data;
    })
}
onMounted(() => {
  GetDeathInfo();
  GetDeathCauseList();
  GetCooter();
})

</script>
<style>
    
</style>